<template>
    <div class="SignList">
        <!--        面包导航-->
        <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>签到管理</el-breadcrumb-item>
            <el-breadcrumb-item>签到任务表</el-breadcrumb-item>
        </el-breadcrumb>
        <!--        卡片-->
        <el-card class="box-card">
            <!--            搜索区域-->
            <el-row :gutter="20">
                <el-col :span="3">
                    <el-date-picker
                            v-model="queryInfo.createDate"
                            type="date"
                            placeholder="选择日期">
                    </el-date-picker>
                </el-col>
                <el-col :span="8">
                    <el-input placeholder="请输入任务名"  v-model="queryInfo.name" clearable>
                        <el-button slot="append" icon="el-icon-search" @click="search" ></el-button>
                    </el-input>
                </el-col>
            </el-row>
            <!--            表格区域-->
            <el-table :data="signList" border>
                <el-table-column type="index"></el-table-column>
                <el-table-column label="任务名字" prop="ewname"></el-table-column>
                <el-table-column label="任务时间" prop="createDate"></el-table-column>
                <el-table-column label="备注" prop="codes" >
                    <template slot-scope="scope">
                        <el-tag v-if="scope.row.codes ===0" >未开启</el-tag>
                        <el-tag type="success" v-else-if="scope.row.codes ===1">已开启</el-tag>
                        <el-tag type="info" v-else-if="scope.row.codes ==2">已结束</el-tag>
                    </template>
                </el-table-column>
<!--                <el-table-column label="操作"  width="180px">-->
<!--                    <template slot-scope="scope">-->
<!--                        &lt;!&ndash;                            修改&ndash;&gt;-->
<!--                        <el-button type="primary" icon="el-icon-edit" size="mini" @click="upSign(scope.row)"></el-button>-->
<!--                    </template>-->
<!--                </el-table-column>-->
            </el-table>
            <!--                分页-->
            <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page="queryInfo.page"
                    :page-sizes="[5,10,20,50]"
                    :page-size="queryInfo.size"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="total">
            </el-pagination>
        </el-card>
    </div>
</template>

<script>
    export default {
        name: "SignList",
        data(){
            return{
                signList: [],
                total: 0,
                queryInfo:{
                    page: 1,
                    size: 10,
                },
            }
        },
        created() {
            this.getSignList()
        },
        methods:{
            async getSignList(){
                const {data: res} = await this.$http.get('Sign/getAllSignList',{
                    params: this.queryInfo
                })
                if(res.code !== 200) return this.$message.error(res.message)
                this.signList = res.data.data
                this.total = res.data.total
            },
            //监听pagesize的改变
            handleSizeChange(newSize){
                this.queryInfo.size = newSize
                this.getSignList()
            },
            //页码值改变
            handleCurrentChange(newPage){
                this.queryInfo.page = newPage
                this.getSignList()
            },
        }
    }
</script>

<style scoped>

</style>